import QuestionaireBasic from '@/model/questionaire/QuestionaireBasic';
import { SETTINGINDEX, SETTINGSETTING } from '@/router/route-name';
import { defineStore } from 'pinia';
import { useManageQueryStore } from '../manage';
interface TopNavState {
  isLoading: boolean;
  /**侧边栏导航 */
  nav: string;

  /** 顶部 */
  top: string;

  /** 当前选择queid */
  queId: string;
}
export const useTopNavStore = defineStore({
  id: 'TopNavStore',
  state: (): TopNavState => ({
    isLoading: false,
    nav: SETTINGINDEX,
    top: SETTINGSETTING,
    queId: '',
  }),
  getters: {
    /**
     * 获取当前路由
     * @returns
     */
    getNav(): string {
      return this.nav;
    },

    getTop(): string {
      return this.top;
    },

    getSelect(): QuestionaireBasic[] {
      const manageStore = useManageQueryStore();

      return manageStore.result;
    },
  },
  actions: {
    /**
     * 设置当前路由
     * @param value
     */
    setNav(value: TopNavState['nav']) {
      this.nav = value;
    },

    setTop(value: TopNavState['top']) {
      this.top = value;
    },

    reSet() {
      this.setNav(SETTINGINDEX);
      this.setTop(SETTINGSETTING);
    },
  },
});
